using System;
using UnityEngine;
using Unity.VisualScripting;
using ResourceUpdateFailureEventArgs = UnityGameFramework.Runtime.ResourceUpdateFailureEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Update")]
    [UnitSurtitle("Failure")]
    public sealed class ResourceUpdateFailure : FrameworkEventUnit<ResourceUpdateFailureEventArgs>
    {
        protected override int EventId => ResourceUpdateFailureEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceUpdateFailure;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadUri
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput RetryCount
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput TotalRetryCount
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ErrorMessage
        {
            get;
            private set;
        }

        
        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            DownloadUri = ValueOutput<string>(nameof(DownloadUri));
            RetryCount = ValueOutput<int>(nameof(RetryCount));
            TotalRetryCount = ValueOutput<int>(nameof(TotalRetryCount));
            ErrorMessage = ValueOutput<string>(nameof(ErrorMessage));
        }

        protected override void AssignArguments(Flow flow, ResourceUpdateFailureEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.Name);
            flow.SetValue(DownloadUri, args.DownloadUri);
            flow.SetValue(RetryCount, args.RetryCount);
            flow.SetValue(TotalRetryCount, args.TotalRetryCount);
            flow.SetValue(ErrorMessage, args.ErrorMessage);
        }
    }
}